package com.hc.tenant.service.impl;

import java.util.List;
import com.hc.common.core.utils.DateUtils;
import com.hc.tenant.domain.MqttMsgSend;
import com.hc.tenant.mapper.MqttMsgSendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hc.tenant.service.IMqttMsgSendService;

/**
 * mqttService业务层处理
 *
 * @author yjz
 * @date 2021-04-07
 */
@Service
public class MqttMsgServiceImpl implements IMqttMsgSendService
{
    @Autowired
    private MqttMsgSendMapper mqttMsgSendMapper;

    /**
     * 查询mqtt
     *
     * @param msgId mqttID
     * @return mqtt
     */
    @Override
    public MqttMsgSend selectMqttMsgSendById(Long msgId)
    {
        return mqttMsgSendMapper.selectMqttMsgSendById(msgId);
    }

    /**
     * 查询mqtt列表
     *
     * @param mqttMsgSend mqtt
     * @return mqtt
     */
    @Override
    public List<MqttMsgSend> selectMqttMsgSendList(MqttMsgSend mqttMsgSend)
    {
        return mqttMsgSendMapper.selectMqttMsgSendList(mqttMsgSend);
    }

    /**
     * 查询 失败次数少于限制次的 mqtt 消息列表
     * */

    @Override
    public List<MqttMsgSend> selectMqttMsgSendLimitRetryList(int retry)
    {
        return mqttMsgSendMapper.selectMqttMsgSendLimitRetryList(retry);
    }



    /**
     * 新增mqtt
     *
     * @param mqttMsgSend mqtt
     * @return 结果
     */
    @Override
    public int insertMqttMsgSend(MqttMsgSend mqttMsgSend)
    {
        mqttMsgSend.setCreateTime(DateUtils.getNowDate());
        return mqttMsgSendMapper.insertMqttMsgSend(mqttMsgSend);
    }

    /**
     * 修改mqtt
     *
     * @param mqttMsgSend mqtt
     * @return 结果
     */
    @Override
    public int updateMqttMsgSend(MqttMsgSend mqttMsgSend)
    {
        return mqttMsgSendMapper.updateMqttMsgSend(mqttMsgSend);
    }

    /**
     * 批量删除mqtt
     *
     * @param msgIds 需要删除的mqttID
     * @return 结果
     */
    @Override
    public int deleteMqttMsgSendByIds(Long[] msgIds)
    {
        return mqttMsgSendMapper.deleteMqttMsgSendByIds(msgIds);
    }

    /**
     * 删除mqtt信息
     *
     * @param msgId mqttID
     * @return 结果
     */
    @Override
    public int deleteMqttMsgSendById(Long msgId)
    {
        return mqttMsgSendMapper.deleteMqttMsgSendById(msgId);
    }
}